<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : manageProduct.xsl
    Created on : April 16, 2013, 1:32 PM
    Author     : NganNLK60334
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pro="http://xml.netbeans.org/schema/products" version="1.0">
    <xsl:output method="html"/>
    <xsl:param name="type" select="'productlist'"/>
    <xsl:param name="context" select="'/XMLProject'"/>
    <xsl:template match="/">
        <xsl:if test="$type='productlist'">
            <xsl:call-template name="prolistcontaint"/>
        </xsl:if>
    </xsl:template>

    <xsl:template name="prolistcontaint">
        <div id="test">
            <table width="100%">
                <tr>

                    <th>Image</th>
                    <th>Name</th>
                    <th>Description</th>
                    <th>CategoryID</th>
                    <th>Price</th>
                    <th>Quantity In Stock</th>
                    <th>isShow</th>
                    <th>Edit</th>



                </tr>
                <xsl:for-each select="pro:products/pro:product">
                    <tr>
                        <td>
                            <div style="width:120px; height:91px;">
                                <img width="100%" height="100%">
                                    <xsl:attribute name="src"><xsl:value-of select = "$context"/>/Pictures/<xsl:value-of select = "pro:productImg"/>
                                    </xsl:attribute>
                                </img>
                            </div>

                        </td>

                        <td>
                            <xsl:element name="input">
                                <xsl:attribute name="type">text</xsl:attribute>
                                <xsl:attribute name="name">productName</xsl:attribute>
                                <xsl:attribute name="id">txtName<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="value">
                                    <xsl:value-of select ='pro:productName'/>
                                </xsl:attribute>

                            </xsl:element>
                        </td>

                        <td>
                            <xsl:element name="textarea">
                                <xsl:attribute name="type">text</xsl:attribute>
                                <xsl:attribute name="name">description</xsl:attribute>
                                <xsl:attribute name="id">txtdescription<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:value-of select ='pro:description'/>
                            </xsl:element>
                        </td>
                        <td>
                            <xsl:value-of select="pro:categoryID"/>
                            <xsl:element name="input">
                                <xsl:attribute name="type">hidden</xsl:attribute>
                                <xsl:attribute name="name">txtcategoryID</xsl:attribute>
                                <xsl:attribute name="id">txtcategoryID<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="value">
                                    <xsl:value-of select ='pro:categoryID'/>
                                </xsl:attribute>
                                <xsl:attribute name="readonly"></xsl:attribute>
                            </xsl:element>
                        </td>




                        <td>
                            <xsl:element name="input">
                                <xsl:attribute name="type">hidden</xsl:attribute>
                                <xsl:attribute name="name">txtID</xsl:attribute>
                                <xsl:attribute name="id">txtID<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="value">
                                    <xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="readonly"></xsl:attribute>
                            </xsl:element>
                            <xsl:element name="input">
                                <xsl:attribute name="style">width:30px;</xsl:attribute>

                                <xsl:attribute name="type">text</xsl:attribute>
                                <xsl:attribute name="name">price</xsl:attribute>
                                <xsl:attribute name="id">txtprice<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="value">
                                    <xsl:value-of select ='pro:price'/>
                                </xsl:attribute>
                            </xsl:element>
                        </td>

                        <td>
                            <xsl:element name="input">
                                <xsl:attribute name="type">text</xsl:attribute>
                                <xsl:attribute name="name">txtQuantityInStock</xsl:attribute>
                                <xsl:attribute name="id">txtQuantityInStock<xsl:value-of select ='pro:productID'/>
                                </xsl:attribute>
                                <xsl:attribute name="style">width:30px;</xsl:attribute>
                                <xsl:attribute name="value">
                                    <xsl:value-of select ='pro:quantityInStock'/>
                                </xsl:attribute>
                            </xsl:element>
                        </td>
                        <td>
                            <button>
                                <xsl:attribute name = "proId">
                                    <xsl:value-of select ="pro:productID"/>
                                </xsl:attribute>
                                <xsl:attribute name="proIsShow">
                                    <xsl:value-of select ="pro:isShow"/>
                                </xsl:attribute>
                                <xsl:attribute name = "class">
                                    <xsl:text>isShow</xsl:text>
                                </xsl:attribute>
                                <xsl:choose>
                                    <xsl:when test="pro:isShow='true'">
                                        <xsl:text>Hide</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>Show</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </button>
                        </td>

                        <td>
                             <button>
                                 <xsl:attribute name = "proId">
                                    <xsl:value-of select ="pro:productID"/>
                                </xsl:attribute>
                                <xsl:attribute name = "class">
                                    <xsl:text>isSave</xsl:text>
                                </xsl:attribute>
                                <xsl:text>Save</xsl:text>
                            </button>
                        </td>

<!--                                <td>
                                <a href="AdminController?btnAction=editProduct">Lưu </a>
                                    <button type="submit" name="btnAction" value ="deleteProduct">Delete</button>
                                </td>-->


                    </tr>
                      
                </xsl:for-each>
            </table>
        </div>
        </xsl:template>
</xsl:stylesheet>
